home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 10139 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.1 KB

  1. Path: Inter.NL.net!usenet
  2. From: Auke.Reitsma@net.HCC.nl (Auke Reitsma)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Limiting stdin input to "n" chars
  5. Date: Fri, 15 Mar 1996 18:56:25 GMT
  6. Organization: Inter.NL.net, The Internet Provider in The Netherlands.
  7. Message-ID: <4icer1$df5@altrade.nijmegen.inter.nl.net>
  8. References: <4hqfmc$un7@thorn.cc.usm.edu>
  9. Reply-To: Auke.Reitsma@net.HCC.nl
  10. NNTP-Posting-Host: rt99-4.rotterdam.nl.net
  11. X-Newsreader: Forte Free Agent 1.0.82
  12.  
  13. rmfulce@ocean.st.usm.edu (Mike Fulce) wrote:
  14.  
  15. > How do you limit the number of characters read from stdin?  What I want to do 
  16. > is to automatically do a carriage return after a user enters say.. 2 digits.  
  17. > I've written a few programs using scanf to get input, but it won't work for 
  18. > what I need now. (I think it's because scanf is buffered I/O?).  
  19.  
  20. > Please e-mail all responses to me and I will post a summary.
  21.  
  22. Do character by character input with e.g. getch() or getchar()
  23. /* (Non-ISO/ANSI) */ or fgetc( stdin ) /* ISO/ANSI */
  24. Or use fgets( your_buffer, number_of_chars, stdin ) /* ANSI */
  25.  
  26.  
  27. Greetings from Delft, The Netherlands.
  28.  
  29. Auke Reitsma
  30.  
  31.